<?php
use yii\helpers\Url;
use yii\helpers\Html;
use yii\widgets\LinkPager;
?>
<link rel="stylesheet" type="text/css" href="/assets/css/youwenbida.css"/>
<link rel="stylesheet" type="text/css" href="/assets/css/public1.css"/>
<div class="main">
<div id='list'>
<div class="left">
    	<h2>
            <span class="ques"><a href="<?= Url::to(['questions/index'])?>">问答</a></span>
            <span class="release"><a href="<?= Url::to(['questions/release'])?>">发布问题</a></span>
        </h2>
        <p>
            <a href="<?= Url::to(['questions/index'])?>?action=new">最新</a>
            <a href="<?= Url::to(['questions/index'])?>?action=hot">最热</a>
            <a href="<?= Url::to(['questions/waiting'])?>?action=wait">等待回复</a>
            <a href="<?= Url::to(['questions/course'])?>?action=course">课程问答</a>
        </p>
      <div class="left1">
	  <?php 
        if(empty($name)){
            echo "抱歉！内容暂时不存在";
        }
        foreach($name as $key=>$val){
      ?>
      	<dl>
        	<dt><a href="#"><img src="http://files.bwphp.com/<?= Html::encode($val['user_thumb'])?>" width="67" height="67" /></a></dt>
            <dd><a href="<?= Url::to(['questions/details'])?>?ques_id=<?php echo $val['ques_id']?>"><?= Html::encode($val['user_name']);?></a></dd>
        </dl>
		<?php }?>
      </div>
        <div class="left2" style="margin-top:16px;">
			<?php foreach($name as $key=>$val){?>
                <div class="left3">
                <dl>
                    <dt>
                    <h4><a href="<?= Url::to(['questions/details'])?>?ques_id=<?php echo $val['ques_id']?>"><?= Html::encode($val['ques_name'])?></a></h4>
                    
                    <h6><span>提问时间：
                    <?php  
                        $dur = time()-$val['ques_addtime'];
                        /*暂时没想到怎么做、先做成这样的*/
                        if($dur<60){
                            echo $dur."秒前";
                        }else{
                            if($dur<3600){
                                echo floor($dur/60)."分钟前";
                            }else{
                                if($dur<86400){
                                    echo floor($dur/3600)."小时前";
                                }else{
                                    if($dur<604800){
                                        echo floor($dur/86400)."天前";
                                    }else{
                                        if($dur<2592000){
                                            echo floor($dur/604800)."周前";
                                        }else{
                                            if($dur<31104000){
                                                echo floor($dur/2592000)."月前";
                                            }else{
                                                if($dur>31104000){
                                                    echo floor($dur/31104000)."年前";
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        echo $year;
                    ?>

                    </span>&nbsp;<a href=''><?= Html::encode($val['queslabel_name'])?>&nbsp;</a>
                    
                    <?php if(!empty($val['course_name'])){?>
                    <a href=''>来源:<?= Html::encode($val['course_name'])?></a>
                    <?php }?>
                    </h6>
                    </dt>
                    <dd>
					<span><?= Html::encode($val['ques_answersum'])?></span>
					<span><?= Html::encode($val['ques_viewsum'])?></span><br/>
                    <a href="#">回答</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">浏览</a>
					</dd>   
                </dl>


</div>
				<?php }?>

        <?php echo LinkPager::widget([
            'pagination' =>$pages,
            'prevPageLabel'=>'上一页',
            'nextPageLabel'=>'下一页',
            
        ]);?>
      </div> 
        
    </div>
</div>  
    <div class="right">
    	<div class="right1">
        <h4>注意！</h4>
            <?php foreach ($notice as $key => $no) {?>
            <p><?php echo $key+1;?>、<?php echo $no['config_value']?><br/><br/></p>
            <?php }?>
        </div>
        <h3>热门标签</h3>
        <div class="right1">
        <form>
		<?php foreach($label as $key=>$val){?>
			<a href="<?= Url::to(['questions/labsearch'])?>?label_id=<?= Html::encode($val['queslabel_id'])?>" style="cursor:pointer;" >
                <font style="font-size:20px;border:2px solid red" >
                    <?= Html::encode($val['queslabel_name'])?>
                </font>
            </a>
		<?php }?>
        </form>
        </div>
        <h3>热门问题</h3>
        <ul>
        	<?php foreach ($hot as $key => $hotques) {?>
            <li><a href="#"><?php echo $hotques['ques_name']?></a><br /><span>阅读（<?php echo $hotques['ques_viewsum']?>）</span></li>
            <?php }?>
        </ul>
    
    </div>

</div>